import qs from "qs";
import request from "@/utils/request";
import {
  parsePageOpts
} from "@/utils";


export function addArticle(article) {
  return request({
    url: "/admin/article",
    method: "post",
    data: article
  });
}

export function getArticleList(pageOpts) {
  pageOpts = parsePageOpts(pageOpts)
  return request({
    url: `/admin/article?${qs.stringify(pageOpts)}`,
    method: "get",
  });
}

export function getArticle(id) {
  return request({
    url: `/admin/article/${id}`,
    method: "get",
  });
}
export function updateArticle(id, article) {
  return request({
    url: `/admin/article/${id}`,
    method: "put",
    data: article
  });
}


export function delArticle(id) {
  return request({
    url: `/admin/article/${id}`,
    method: "delete",
  });
}